#include "catch.hpp"

#include "common/base64.h"
#include "common/log.h"


TEST_CASE("base64 tests", "[base64]") {
    using namespace std;
    using namespace evm;

    string data = "Hello, I'm a boy. My name is EVM.";
    auto encoded = base64::encode(data);
    auto decoded = base64::decode(encoded);
    log_info("\"{}\", encoded to \"{}\", decoded to \"{}\"", data, encoded, decoded);
    REQUIRE(data == decoded);

    string error_encoded = "Not base64 encoded data ~!@#$%^&*()";
    REQUIRE_THROWS(base64::decode(error_encoded));
    REQUIRE_THROWS_AS(base64::decode(error_encoded), invalid_argument);
}
